/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package BLO;

import DAO.TaskDAO;
import DTO.Date;
import DTO.Tasks;
import java.sql.SQLException;
import util.SupportUtil;

/**
 *
 * @author ThanhTai
 */
public class TaskBLO {

    public void getTasksBySearch(String xmlFilePath, Integer minestoneID, String taskName,
            Date startDay, Date endDay, String status) {
        try {
            TaskDAO dao = new TaskDAO();
            String taskNameNew = "%"+taskName + "%";
            String condition = " where MinestoneID = " + minestoneID.toString()
                    + " and (TaskName like '"+taskNameNew
                    + "' or StartDay = '" + startDay.getDateJavaUtil().toString()
                    + "' or EndDay = '" + endDay.getDateJavaUtil().toString()
                    + "')";
            Tasks tasks = dao.GetAllTask(condition);
            SupportUtil util = new SupportUtil();
            util.marshal(xmlFilePath, tasks);

        } catch (SQLException exsql) {
            exsql.printStackTrace();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    public void getTasksByUser(String xmlFilePath, String username) {
        try {
            TaskDAO dao = new TaskDAO();
            String condition = " where username = '" + username +"'";
            Tasks tasks = dao.GetAllTask(condition);
            SupportUtil util = new SupportUtil();
            util.marshal(xmlFilePath, tasks);

        } catch (SQLException exsql) {
            exsql.printStackTrace();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}
